import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:vape_xe/utils/utils.dart';

class WithdrawAddressNewController extends GetxController {
  /// 响应式成员变量

  /// 成员变量
  late final TextEditingController contentController;
  late final FocusNode focusNode;

  /// 事件
  Future<void> addAddress() async {
    if (contentController.text.isEmpty) {
      toast('Address empty'.tr);
      return;
    }
    Loading.show();
    await Request().post('/userBand/goBand', {
      'type': Get.arguments['type'],
      'uniqueId': contentController.text,
    }).then((result) {
      Get.back(result: true);
    });
  }

  /// 生命周期
  @override
  void onInit() {
    super.onInit();
    contentController = TextEditingController();
    focusNode = FocusNode();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      focusNode.requestFocus();
    });
  }

  @override
  void onClose() {
    focusNode.dispose();
    super.onClose();
  }
}
